home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / AdobeExamples / NX_ImportAdv / ImportPanel.m < prev    next >
Encoding:
Text File  |  1992-12-19  |  3.8 KB  |  164 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34.  *    ImportPanel.m
  35.  *
  36.  *    Necessary because of the difficulty of obtaining a copy
  37.  *    of the OpenPanel. This subclass of panel uses the OpenPanel
  38.  *    panel and switches the panel from an OpenPanel to an ImportPanel.
  39.  *    The panel is switched back when needed. Not recommended but
  40.  *    seemingly the only way.
  41.  *
  42.  */
  43.  
  44. #import "ImportPanel.h"
  45.  
  46. #import <appkit/Button.h>
  47. #import <appkit/Matrix.h>
  48. #import <appkit/TextField.h>
  49. #import <appkit/View.h>
  50. #import <appkit/nextstd.h>
  51.  
  52. #import <objc/hashtable.h>
  53. #import <objc/List.h>
  54. #import <objc/Object.h>
  55. #import <strings.h>
  56.  
  57. @implementation ImportPanel
  58.  
  59. /*
  60. *    Assign the accessory id to the ImportPanel instance variable.
  61. *    Find the matrix of buttons in the accessory view and the open
  62. *    title text. These ids will be used at later times.
  63. */
  64. - setImportAccessory:anObject
  65. {
  66.         int        i, j;
  67.  
  68.     id        subviewlist, subview;
  69.  
  70.     /* Search for the button matrix in the accessory view. */
  71.     accessoryId = anObject;
  72.     subviewlist = [[[accessoryId  subviews]  objectAt:0]  subviews];
  73.     j = [subviewlist  count];
  74.     for (i = 0; i < j; i++)
  75.     {
  76.         subview = [subviewlist  objectAt:i];
  77.         if ([subview  isKindOf:[Matrix  class]])
  78.         {
  79.             buttonsId = subview;
  80.             if (switchId)
  81.                 break;
  82.         }
  83.         else if ([subview  isKindOf:[Button  class]])
  84.         {
  85.             switchId = subview;
  86.             if (buttonsId)
  87.                 break;
  88.         }
  89.     }
  90.  
  91.     /*
  92.     *  Search for the title textfield in the panel. (Not a recommended
  93.     *  approach but one of the only ways to get at the title.)
  94.     */
  95.     subviewlist = [contentView  subviews];
  96.     j = [subviewlist  count];
  97.     for (i = 0; i < j; i++)
  98.     {
  99.         subview = [subviewlist  objectAt:i];
  100.         if ([subview isKindOf:[TextField  class]])
  101.         {
  102.             if (strcmp("Open", [subview  stringValue]) == 0)
  103.             {
  104.                 titleId = subview;
  105.                 break;
  106.             }
  107.         }
  108.     }
  109.  
  110.     return self;
  111. }
  112.  
  113. - setOpen
  114. {
  115.     if (strcmp("Open", [titleId  stringValue]) != 0)
  116.     {
  117.         [titleId  setStringValue:"Open"];
  118.         [titleId  display];
  119.  
  120.         [self  setAccessoryView:NULL];
  121.         if (idirectory)
  122.             NX_FREE(idirectory);
  123.         idirectory = NXCopyStringBuffer(directory);
  124.         [self  allowMultipleFiles:YES];
  125.     }
  126.  
  127.     return self;
  128. }
  129.  
  130. - setImport
  131. {
  132.     if (strcmp("Import", [titleId  stringValue]) != 0)
  133.     {
  134.         [titleId  setStringValue:"Import"];
  135.         [titleId  display];
  136.  
  137.         [self  setAccessoryView:accessoryId];
  138.         if (idirectory)
  139.             [self  setDirectory:idirectory];
  140.         [self  allowMultipleFiles:NO];
  141.     }
  142.  
  143.     return self;
  144. }
  145.  
  146. - setFormat:(int) aFormat
  147. {
  148.     [buttonsId  selectCellWithTag:aFormat];
  149.  
  150.     return self;
  151. }
  152.  
  153. - (int) format
  154. {
  155.     return  [buttonsId  selectedTag];
  156. }
  157.  
  158. - (BOOL) dragToSize
  159. {
  160.     return  [switchId  state];
  161. }
  162.  
  163. @end
  164.